package cn.bgs.service.impl;

import cn.bgs.CommunityManagement.pojo.Community;
import cn.bgs.mapper.ActivityMapper;
import cn.bgs.page.PageRequest;
import cn.bgs.pojo.CommunityActivities;
import cn.bgs.pojo.Maintenances;
import cn.bgs.service.ActivityService;
import cn.bgs.utils.R;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ActivityServiceImpl implements ActivityService {
    @Autowired
    private ActivityMapper activityMapper;
    @Override
    public PageInfo<CommunityActivities> activitySelect(PageRequest pageRequest,String activityTheme) {
        PageHelper.startPage(pageRequest.getPageNum(),pageRequest.getPageSize());
        PageInfo<CommunityActivities> userPageInfo = new PageInfo<>(activityMapper.selectAll(activityTheme));
        return userPageInfo;
    }

    @Override
    public R middle() {
        List<Community> list = activityMapper.middle();
        return R.ok().data("list",list);
    }

    @Override
    public R activityAdd(CommunityActivities communityActivities) {
        int i = activityMapper.activityAdd(communityActivities);
        return R.ok().data("i",i);
    }

    @Override
    public R activityUpdate(CommunityActivities communityActivities) {
        int i = activityMapper.activityUpdate(communityActivities);
        return R.ok().data("i",i);
    }

    @Override
    public R activityDelect(Integer communityActivitiesId) {
        int i = activityMapper.activityDelect(communityActivitiesId);
        return R.ok().data("i",i);
    }
}
